{
  "name": "Case 6 – Medical Research Grant Evaluation",
  "nodes": [
    {
      "name": "On form submission",
      "type": "n8n-nodes-base.formTrigger",
      "typeVersion": 2,
      "position": [0, 0],
      "parameters": {
        "formTitle": "Medical Research Grant Proposal Submission",
        "formDescription": "Upload research proposal for grant evaluation",
        "formFields": {
          "values": [
            { "fieldLabel": "Principal Investigator", "requiredField": true },
            { "fieldLabel": "Email id", "fieldType": "email", "requiredField": true },
            {
              "fieldLabel": "Research_Proposal",
              "fieldType": "file",
              "acceptFileTypes": ".pdf",
              "requiredField": true
            }
          ]
        }
      }
    },
    {
      "name": "Upload file",
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [220, 0],
      "parameters": {
        "inputDataFieldName": "Research_Proposal",
        "name": "={{ $json['Principal Investigator'] + '_Grant_Proposal' }}",
        "folderId": "REPLACE_WITH_GRANTS_FOLDER_ID"
      }
    },
    {
      "name": "Download file",
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [420, 0],
      "parameters": {
        "operation": "download",
        "fileId": "={{ $json.id }}"
      }
    },
    {
      "name": "Extract Proposal",
      "type": "n8n-nodes-base.extractFromFile",
      "typeVersion": 1,
      "position": [620, 0],
      "parameters": {
        "operation": "pdf"
      }
    },
    {
      "name": "Download Grant Guidelines",
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [820, 0],
      "parameters": {
        "operation": "download",
        "fileId": "REPLACE_WITH_GRANT_GUIDELINES_FILE_ID"
      }
    },
    {
      "name": "Extract Grant Guidelines",
      "type": "n8n-nodes-base.extractFromFile",
      "typeVersion": 1,
      "position": [1020, 0],
      "parameters": {
        "operation": "pdf"
      }
    },
    {
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 3,
      "position": [220, 260],
      "parameters": {
        "promptType": "define",
        "text": "=Research Proposal:\n{{ $('Extract Proposal').item.json.text }}\n\nGrant Evaluation Guidelines:\n{{ $('Extract Grant Guidelines').item.json.text }}",
        "options": {
          "systemMessage": "You are a Medical Research Grant Review Committee Member.\n\nYOUR OBJECTIVE:\nAllocate limited research funding to proposals with the highest scientific value, feasibility of execution, and potential clinical or societal impact.\n\nANALYSIS FRAMEWORK (MANDATORY):\n1. SCIENTIFIC NOVELTY – originality and advancement beyond existing literature.\n2. METHODOLOGICAL FEASIBILITY – study design, cohort size, data quality, execution capability.\n3. IMPACT POTENTIAL – relevance to unmet medical needs and translational value.\n4. TEAM & GOVERNANCE – PI credentials, prior grants, institutional capability.\n5. BUDGET JUSTIFICATION – cost realism and alignment to objectives.\n\nYOU MUST PRODUCE ONE JSON OBJECT WITH EXACTLY THESE FIELDS. ALL FIELDS ARE MANDATORY.\n\nJSON SCHEMA (STRICT):\n{\n  \"Proposal_ID\": \"string\",\n  \"Principal_Investigator\": \"string\",\n  \"Institution\": \"string\",\n  \"Research_Domain\": \"string\",\n  \"Grant_Amount_Requested_INR_Cr\": \"number\",\n  \"Scientific_Novelty_Score_out_of_10\": \"number\",\n  \"Methodological_Feasibility_Score_out_of_10\": \"number\",\n  \"Impact_Potential_Score_out_of_10\": \"number\",\n  \"Team_Capability_Assessment\": \"Strong | Adequate | Weak\",\n  \"Budget_Justification_Assessment\": \"Reasonable | Borderline | Excessive\",\n  \"Overall_Score_out_of_100\": \"number\",\n  \"Funding_Recommendation\": \"Shortlisted | Rejected\",\n  \"Key_Review_Comments\": \"string\"\n}\n\nINSTRUCTIONS:\n- Numeric fields MUST be numbers.\n- Do NOT add or remove fields.\n- Output ONLY valid JSON.\n- IMMEDIATELY call the Google Sheets Append Row tool using this JSON."
        }
      }
    },
    {
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1,
      "position": [0, 420],
      "parameters": {
        "model": {
          "mode": "list",
          "value": "gpt-4.1-mini"
        }
      }
    },
    {
      "name": "Append row",
      "type": "n8n-nodes-base.googleSheetsTool",
      "typeVersion": 4,
      "position": [420, 460],
      "parameters": {
        "operation": "append",
        "documentId": "REPLACE_WITH_GOOGLE_SHEET_ID",
        "sheetName": "Medical Research Grant – Proposal Evaluation Register"
      }
    },
    {
      "name": "Send Email",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2,
      "position": [420, 260],
      "parameters": {
        "sendTo": "={{ $('On form submission').item.json['Email id'] }}",
        "subject": "Medical Research Grant – Evaluation Outcome",
        "message": "={{ 'Dear ' + $('On form submission').item.json['Principal Investigator'] + ',<br><br>Your research proposal has been reviewed under the grant evaluation process. You will be informed of the next steps shortly.<br><br>Grant Review Committee' }}"
      }
    }
  ],
  "connections": {
    "On form submission": { "main": [[{ "node": "Upload file" }]] },
    "Upload file": { "main": [[{ "node": "Download file" }]] },
    "Download file": { "main": [[{ "node": "Extract Proposal" }]] },
    "Extract Proposal": { "main": [[{ "node": "Download Grant Guidelines" }]] },
    "Download Grant Guidelines": { "main": [[{ "node": "Extract Grant Guidelines" }]] },
    "Extract Grant Guidelines": { "main": [[{ "node": "AI Agent" }]] },
    "OpenAI Chat Model": { "ai_languageModel": [[{ "node": "AI Agent" }]] },
    "Append row": { "ai_tool": [[{ "node": "AI Agent" }]] },
    "AI Agent": { "main": [[{ "node": "Send Email" }]] }
  },
  "active": false
}
